package com.douqu.game.battle;

import com.douqu.game.battle.server.GameServer;
import com.douqu.game.core.factory.LoadFactory;
import com.douqu.game.core.util.LogUtils;

//import com.douqu.game.battle.server.BattleGroup;


/**
 * Author : Bean
 * 2017-07-06 18:04
 */
public class StartServer {
    
    public static void main(String[] args)
    {

        if (args.length > 0)
        {
            LoadFactory.FIXED_CONFIG_PATH = args[0];
        }
        if (args.length > 1)
        {
            LoadFactory.DYNAMIC_CONFIG_PATH = args[1];
        }

        LogUtils.warn("FIXED_CONFIG_PATH ========> ", LoadFactory.FIXED_CONFIG_PATH);
        LogUtils.warn("DYNAMIC_CONFIG_PATH ==========> ", LoadFactory.DYNAMIC_CONFIG_PATH);

        GameServer.getInstance().start();

//        test();

    }

    public static int battleId;

//    public static void test()
//    {
//        Map<Integer, BattleGroup> battleMap = GameServer.getInstance().getWorldManager().getBattleControllerGroup();
//        BattleGroup battleGroup1 = new BattleGroup(1);
//        battleMap.put(battleGroup1.getGroup(), battleGroup1);
//
//        BattleGroup battleGroup2 = new BattleGroup(2);
//        battleMap.put(battleGroup2.getGroup(), battleGroup2);
//
//        BattleGroup battleGroup3 = new BattleGroup(3);
//        battleMap.put(battleGroup3.getGroup(), battleGroup3);
//
//        while(true)
//        {
//            TimeUtils.sleep(2* ConstantFactory.UPDATE_BATTLE_TIME);
//            DataFactory.currentTime = System.currentTimeMillis();
//
////            int r = com.bean.core.util.Utils.getRandom(5);
////            if(r == 3)
////            {
//                boolean addResult = false;
//            Player source = new Player(new WorldInfo());
//            source.setObjectIndex(battleId + "+++");
//                PlayerController playerController = new PlayerController(source, null);
//            PVEInstanceController battleController = new PVEInstanceController((++battleId) + "", playerController, playerController, SGCommonProto.E_BATTLE_TYPE.BATTLE_TYPE_PVP_ARENA, battleId+"");
//                LogUtils.info("添加一场战斗 -> " + battleController.getId());
//            battleController.setCreateTime((int) (DataFactory.currentTime/1000));
//                for(Integer key : battleMap.keySet())
//                {
//                    addResult = battleMap.get(key).addBattleController(battleController);
//                    if(addResult)
//                    {
//                        LogUtils.info("添加成功 -> group:" + battleMap.get(key).getGroup());
//                        break;
//                    }
//                }
//
//                if(!addResult)
//                {
//                    LogUtils.info("添加失败,重新生成新的战斗组 -> " + (battleMap.size()+1));
//                    BattleGroup battleGroup = new BattleGroup(battleMap.size()+1);
//                    battleMap.put(battleGroup.getGroup(), battleGroup);
//                    battleGroup.addBattleController(battleController);
//                }
////            }
//        }
//    }



}
